﻿Create Procedure setCustomProfileData
    @UPN varchar(128),
    @FullName nvarchar(250),
    @NumRows int
as

declare @CurrentUtcDate datetime
set        @CurrentUtcDate = getutcdate()

--Either insert a new row of data, or update a pre-existing row
if exists (select 1 from dbo.UserProfiles where UPN = @UPN) 
BEGIN 
	update dbo.UserProfiles
	set	FullName = @FullName,
		NumRows	 = @NumRows,
		LastUpdatedDate	= @CurrentUtcDate
	where UPN = @UPN
END
else
BEGIN
	insert dbo.UserProfiles (UPN, FullName, NumRows, LastUpdatedDate)
    values (@UPN, @FullName, @NumRows, @CurrentUtcDate)
END
